#! /bin/sh

# 该脚本用于在PLDM演示内存隔离效果，先在没什么用，但是先保留

#echo "Hello!"
/bin/mount -a

mkdir -p /dev
/bin/mount -t devtmpfs devtmpfs /dev

cat /etc/motd
/bin/busybox --install -s
#ls /dev
/sbin/mdev -s
#ls /dev
#echo "I'm Guest!"
#ls /rv8
#ls /
#echo "show the files in / "
#ls /
#echo "show the files in /dev"
#ls /dev
#echo "show the files in /etc"
#ls /etc
#echo "show the files in /apps"
#ls /apps
#/etc/hello
#echo "show the files in /gobmk"
#ls -R /gobmk
#echo "show the files in /astar"
#ls /astar

#/astar_rivers_run.sh

chmod +x run_spec.sh
echo "测试spec cpu"
./run_spec.sh
#time /apps/hmmer_base.riscv64-linux-gnu-gcc12.2.0 --fixed 0 --mean 500 --num 500000 --sd 350 --seed 0 /apps/retro.hmm
#echo "run a hello in the Guest Linux!"
#/etc/hello
#echo "开始测试rv8"
#echo "test aes.O3"
#time /apps/aes.O3
#echo "test bigint.O3"
#time /apps/bigint.O3
#echo "test dhrystone.O3"
#time /apps/dhrystone.O3
#echo "test miniz.O3"
#time /apps/miniz.O3
#echo "test norx.O3"
#time /apps/norx.O3
#echo "test primes.O3"
#time /apps/primes.O3
#echo "test qsort.O3"
#time /apps/qsort.O3
#echo "test sha512.O3"
#time /apps/sha512.O3
#echo "结束测试rv8"


#echo "   "
#echo "【开始测试内存隔离机制 】  "
#echo "============================================================="
#echo "【设为 Enclave 内存之前】 读地址 0xa0000000 "
#devmem 0xa0000000 64
#echo "【设为 Enclave 内存之前】 向地址 0xa0000000 写入0xdead"
#devmem 0xa0000000 64 0xdead
#echo "【设为 Enclave 内存之前】 向地址 0xb0000000 写入0x1234"
#devmem 0xb0000000 64 0x1234
#echo "【设为 Enclave 内存之前】 再次读地址 0xa0000000"
#devmem 0xa0000000


#echo "【  设为 Enclave 内存  】"
#devmem 0x90014000 64 0xFFFFFFFFFFFFFFFF
#echo "[IIE CVM Monitor@sbi_enclave_create] enclave_id = 0"
#echo "[IIE CVM Monitor@get_enclave       ] enclave list is empty"
##echo "[IIE CVM Monitor@set_mbmc          ] set Bitmap Base Address to 0x90000000"
##echo "[IIE CVM Monitor@set_mbmc          ] set CSR_MBMC register to 0x90000004"
#echo "[IIE CVM Monitor@sbi_enclave_create] enclave allocating ..."
#echo "[IIE CVM Monitor@sbi_enclave_create] enclave allocation is successful."

#echo "-------------------------------------------------------------"
#echo "【设为 Enclave 内存之后】 再次读地址 0xa0000000 (此时为非法读)"
#devmem 0xa0000000 64 
#echo "【设为 Enclave 内存之后】 再次写地址 0xa0000000 (此时为非法写)"
#devmem 0xa0000000 64 0x1234
#echo "【设为 Enclave 内存之后】 读Enclave之外的地址 0xb0000000 (合法读)"
#devmem 0xb0000000 64
#echo "【设为 Enclave 内存之后】 向Enclave之外的地址 0xb0000000 写入 0x5678(合法写)"
#devmem 0xb0000000 64 0x5678
#echo "【设为 Enclave 内存之后】 再次读Enclave之外的地址 0xb0000000 (合法读)"
#devmem 0xb0000000 64
#echo "============================================================="


/etc/hello












echo "shut down Guest!"
poweroff
#/apps/over # run nemu trap
